package com.sam.book;

/**
 * 最大公约数
 */
public class Gcd {
    public static void main(String[] args) {
        System.out.println(gcd(1000,2421254));
    }

    public static long gcd(long m, long n) {
        long r;
        if (m < n) {//保证m>n
            r = n;
            n = m;
            m = r;
        }

        while (n != 0) {
            r = m % n;
            m = n;
            n = r;
        }
        return m;
    }

}
